Validation and related exception handling improvements #1439
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Deploy board
Front end
Slightly improved the UI for displaying auto promotion config change failures.
Back end
The code base doesn't handle
IllegalArgumentException
everywhere. ChangedIllegalArgumentException
to a subclass ofTeletraanException
, so it can be handled wheneverTeletraanException
is handled. This works because the handling is the same - show users the error.Teletraan service
Validation
Added constraints to the
PromoteBean
. When users tried to save an invalid schedule, it will be rejected by validationException handling
Added
JerseyViolationExceptionMapper
and removed our own handling inGenericExceptionMapper
.JerseyViolationExceptionMapper
is simply better and it provides a Json as the response body (v.s. plain text).Additionally, without
JerseyViolationExceptionMapper
and when an invalid input is caught by validation, the service simply returns 400 without any message, because Jersey's ownConstraintViolationExceptionMapper
handles the exception without invoking ourGenericExceptionMapper
.Junit 5
Added Junit 5 and used it in the resources tests. Note that Junit 5 can run in parallel with Junit 4.
Validations and tests
Currently, there is no validation. Users can save any schedule and they won't know if it is a valid one.
With this change: